from selenium import webdriver
from time import sleep
from selenium.webdriver.common.keys import Keys                          #导入使用键盘的Keys类
driver = webdriver.Chrome()
driver.get("https://www.baidu.com")

driver.find_element_by_id("kw").send_keys("selenium")                #在输入框输入内容
driver.find_element_by_id("kw").send_keys(Keys.BACK_SPACE)            #删除多输入的一个m
driver.find_element_by_id("kw").send_keys(Keys.SPACE)                 # 添加一个空格
driver.find_element_by_id("kw").send_keys("教程")                      # 输入教程
driver.find_element_by_id("kw").send_keys(Keys.CONTROL,"a")            # 全选输入框的内容
driver.find_element_by_id("kw").send_keys(Keys.CONTROL,"c")            #粘贴
driver.find_element_by_id("kw").send_keys(Keys.CONTROL,"x")            #剪切输入框内容
driver.find_element_by_id("kw").send_keys(Keys.CONTROL,"v")            #粘贴输入框内容
driver.find_element_by_id("su").send_keys(Keys.ENTER)                 #用回车键代替单击操作
# driver.find_element_by_id("su").send_keys(Keys.F1)                  #键盘F1~F12
# ............................
# driver.find_element_by_id("su").send_keys(Keys.F12)
# sleep(10)
# driver.quit()
